package com.yifeng.repo.base.security.auth.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by daibing on 2023/8/9.
 */
@Getter
@AllArgsConstructor
public enum SecurityTypeEnum {
    BUSINESS("2B", "2B面向企业B端"),
    CUSTOMER("2C", "2C面向消费者C端"),
    SUPPLY("2S", "2S面向供应链"),
    ;

    @EnumValue
    @JsonValue
    private final String code;

    private final String name;

    private static final Map<String, SecurityTypeEnum> mappings = new HashMap<>(4);

    static {
        for (SecurityTypeEnum value : values()) {
            mappings.put(value.getCode(), value);
        }
    }

    public static SecurityTypeEnum resolve(String code) {
        return (code != null ? mappings.get(code) : null);
    }
}
